<template>
  <div>
    <Main v-model:currentItem="currentItem"/>
    <AddForm/>
    <EditForm/>
  </div>
</template>

<script setup lang="ts">
import Main from './Main/Main.vue'
import {inject, provide, ref} from "vue";
import AddForm from "@/views/Home/AddForm/AddForm.vue";
import EditForm from "@/views/Home/EditForm/EditForm.vue";
import {IListItem} from "@/views/Home/Main/types";

/* 新增 */
const visible = ref(false)
const handleOpenAddModal = () => {
  visible.value = true
}
const handleCloseAddModal = () => {
  visible.value = false
}
provide("visible", visible)
provide("handleOpenAddModal", handleOpenAddModal)
provide("handleCloseAddModal", handleCloseAddModal)

/* 修改 */
const editVisible = ref(false)
// 当前点击行数据
const currentItem = ref<IListItem>({
  key: 0,
  ID: 0,
  title: ""
})
const handleOpenEditModal = () => {
  editVisible.value = true
}
const handleCloseEditModal = () => {
  editVisible.value = false
}
provide("editVisible", editVisible)
provide("currentItem", currentItem)
provide("handleOpenEditModal", handleOpenEditModal)
provide("handleCloseEditModal", handleCloseEditModal)
</script>

<style lang="less" scoped>
</style>
